package com.share.controller.manager;

import com.share.pojo.bo.DriverGeoBo;
import com.share.result.JSONResult;
import com.share.service.IDriverWorkService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "司机对象",description = "司机对象")
@RestController
@RequestMapping("/manager/work")
public class DriverWorkController {
    @Autowired
    private IDriverWorkService driverWorkService;
    @Operation( summary= "司机上线",description = "司机上线")
    @Parameter(name = "onLine",description = "onLine",required = true)
    @PostMapping("/onLine")
    public JSONResult onLine(){
        driverWorkService.onLine();
        return JSONResult.success();
    }

    @Operation( summary= "司机下线",description = "司机下线")
    @Parameter(name = "offLine",description = "offLine",required = true)
    @GetMapping("/offLine/{id}")
    public JSONResult offLine(@PathVariable("id")Long id){
        driverWorkService.offLine(id);
        return JSONResult.success();
    }

    @Operation( summary= "缓存司机坐标",description = "缓存司机坐标")
    @Parameter(name = "geo",description = "geo",required = true)
    @PostMapping("/geo")
    public JSONResult geo(@RequestBody @Valid DriverGeoBo driverGeoBo){
        driverWorkService.geo(driverGeoBo);
        return JSONResult.success();
    }

    @Operation( summary= "获取司机坐标",description = "获取司机坐标")
    @Parameter(name = "getGeo",description = "getGeo",required = true)
    @GetMapping("/getGeo/{driverId}")
    public JSONResult getGeo(@PathVariable("driverId")Long driverId){
        return driverWorkService.getGeo(driverId);
    }

}
